package com.enhinck.dbutilweb.model;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * 分页查询基础类
 *
 * @author huenb
 */
@Data
public class BasePageSearch implements Serializable {
    @ApiModelProperty(value = "分页 当前页", example = "1")
    private Integer pageNum;
    @ApiModelProperty(value = "分页 每页几条", example = "10")
    private Integer numPerPage;

    public BasePageSearch() {
        pageNum = 1;
        numPerPage = 10;
    }

    public BasePageSearch(int pageNum, int numPerPage) {
        super();
        this.pageNum = pageNum;
        this.numPerPage = numPerPage;
    }

    public Integer getPageNum() {
        return pageNum == null ? 1 : pageNum;
    }

    public Integer getNumPerPage() {
        return numPerPage == null ? 10 : numPerPage;
    }

    public <T> T copyPropertiesTo(T target, String... ignoreProperties) {
        BeanUtils.copyProperties(this, target, ignoreProperties);
        return target;
    }
}
